<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>操作元素-修改元素的属性</title>

    <style>
        img {
            width: 300px;
            /* height: ; */
        }
    </style>
</head>

<body>
    <button id="fj1">1</button>
    <button id="fj2">2</button>
    <img src="https://img95.699pic.com/photo/50132/5516.jpg_wh300.jpg" alt="1" title="风景1">
    <script>
        // 1.innerText和innerHTML 改变元素内容
        // 2.src href  
        // 3.id alt title
        // 4.获取的元素.属性 img.src 

        // 修改元素属性 src
        // 1获取元素属性
        var fj1 = document.getElementById('fj1');
        var fj2 = document.getElementById('fj2');
        var img = document.querySelector('img');
        // 2.注册事件  处理程序
        fj1.onclick = function() {
            img.src = "https://img95.699pic.com/photo/50132/5516.jpg_wh300.jpg";
            img.title = '风景1';
        }
        fj2.onclick = function() {
            img.src = "https://img.tukuppt.com/bg_grid/00/14/86/WvJAithG7a.jpg!/fh/350";
            img.title = '风景2';
        }
    </script>
</body>

</html>